<!DOCTYPE html>
<html>
  <head>
    <meta charset='utf-8'>
    <meta content='width=device-width, initial-scale=1.0' name='viewport'>
    <meta content='' name='description'>
    <meta content='Nils Nordman' name='author'>
    <link href='/images/howl.png' rel='shortcut icon'>
    <title>Howl :: Spec - howl.util.Matcher</title>
    <link href="/stylesheets/bootstrap.min.css" media="screen" rel="stylesheet" type="text/css" />
    <link href="/stylesheets/syntax.css" media="screen" rel="stylesheet" type="text/css" />
    <link href="/stylesheets/howl.css" media="screen" rel="stylesheet" type="text/css" />
    <script src="https://code.jquery.com/jquery-1.12.3.min.js" type="text/javascript"></script>
    <script src="/javascripts/bootstrap.min.js" type="text/javascript"></script>
    
    <link href='//fonts.googleapis.com/css?family=Josefin+Slab' rel='stylesheet' type='text/css'>
    <link href='//fonts.googleapis.com/css?family=Open+Sans+Condensed:700' rel='stylesheet' type='text/css'>
  </head>
  <body class='doc doc_spec doc_spec_util doc_spec_util_matcher_spec'>
    <div class='container'>
      <div class='masthead'>
        <ul class='nav nav-pills'>
          <li>
            <a href='/'>
              <span class='glyphicon glyphicon-home'></span>
              Home
            </a>
          </li>
          <li>
            <a href='/doc/'>
              <span class='glyphicon glyphicon-book'></span>
              Documentation
            </a>
          </li>
          <li>
            <a href='/blog/'>
              <span class='glyphicon glyphicon-bullhorn'></span>
              Blog
            </a>
          </li>
          <li>
            <a href='/contact.html'>
              <span class='glyphicon glyphicon-inbox'></span>
              Contact
            </a>
          </li>
        </ul>
      </div>
      <ol class="breadcrumb"><li><a href="/">Home</a></li><li><a href='../../'>Howl Documentation (master branch)</a></li><li>Spec</li><li>Util</li><li>Spec - howl.util.Matcher</li></ol>
      <div class="spec-group spec-group-1">&#x000A;&#x000A;<h1 id="howl.util.matcher">howl.util.Matcher</h1>&#x000A;&#x000A;<h4 id="matches-if-the-search-matches-exactly">matches if the search matches exactly</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">c</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s1">'One'</span><span class="p">,</span><span class="w"> </span><span class="s1">'Green Fields'</span><span class="p">,</span><span class="w"> </span><span class="s1">'two'</span><span class="w"> </span><span class="p">}</span><span class="w">&#x000A;</span><span class="n">m</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Matcher</span><span class="w"> </span><span class="n">c</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s1">'One'</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">m</span><span class="p">(</span><span class="s1">'ne'</span><span class="p">)</span></pre>&#x000A;&#x000A;<h4 id="candidates-are-automatically-converted-to-strings">candidates are automatically converted to strings</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">candidate</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">setmetatable</span><span class="w"> </span><span class="p">{},</span><span class="w"> </span><span class="ss">__tostring:</span><span class="w"> </span><span class="o">-&gt;</span><span class="w"> </span><span class="s1">'auto'</span><span class="w">&#x000A;</span><span class="n">m</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Matcher</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">candidate</span><span class="w"> </span><span class="p">}</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">candidate</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">m</span><span class="p">(</span><span class="s1">'auto'</span><span class="p">)</span></pre>&#x000A;&#x000A;<h4 id="candidates-can-be-multi-valued-tables">candidates can be multi-valued tables</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">c</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s1">'One'</span><span class="p">,</span><span class="w"> </span><span class="s1">'Uno'</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span><span class="w">&#x000A;</span><span class="n">m</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Matcher</span><span class="w"> </span><span class="n">c</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">c</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">m</span><span class="p">(</span><span class="s1">'One'</span><span class="p">)</span></pre>&#x000A;&#x000A;<h4 id="multi-valued-candidates-are-automatically-converted-to-strings">multi-valued candidates are automatically converted to strings</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">candidate</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">setmetatable</span><span class="w"> </span><span class="p">{},</span><span class="w"> </span><span class="ss">__tostring:</span><span class="w"> </span><span class="o">-&gt;</span><span class="w"> </span><span class="s1">'auto'</span><span class="w">&#x000A;</span><span class="n">m</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Matcher</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">candidate</span><span class="p">,</span><span class="w"> </span><span class="s1">'desc'</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">candidate</span><span class="p">,</span><span class="w"> </span><span class="s1">'desc'</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">m</span><span class="p">(</span><span class="s1">'auto'</span><span class="p">)</span></pre>&#x000A;&#x000A;<h4 id="prefers-boundary-matches-over-exact-ones">prefers boundary matches over exact ones</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">c</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s1">'kiss her'</span><span class="p">,</span><span class="w"> </span><span class="s1">'some/stuff/here'</span><span class="p">,</span><span class="w"> </span><span class="s1">'openssh'</span><span class="p">,</span><span class="w"> </span><span class="s1">'sss hhh'</span><span class="w"> </span><span class="p">}</span><span class="w">&#x000A;</span><span class="n">m</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Matcher</span><span class="w"> </span><span class="n">c</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w">&#x000A;  </span><span class="s1">'sss hhh'</span><span class="p">,</span><span class="w">&#x000A;  </span><span class="s1">'some/stuff/here'</span><span class="w">&#x000A;  </span><span class="s1">'openssh'</span><span class="p">,</span><span class="w">&#x000A;</span><span class="p">},</span><span class="w"> </span><span class="n">m</span><span class="p">(</span><span class="s1">'ssh'</span><span class="p">)</span></pre>&#x000A;&#x000A;<h4 id="prefers-early-occurring-matches-over-ones-at-the-end">prefers early occurring matches over ones at the end</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">c</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s1">'Discard all apples'</span><span class="p">,</span><span class="w"> </span><span class="s1">'all aardvarks'</span><span class="w"> </span><span class="p">}</span><span class="w">&#x000A;</span><span class="n">m</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Matcher</span><span class="w"> </span><span class="n">c</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w">&#x000A;  </span><span class="s1">'all aardvarks'</span><span class="p">,</span><span class="w">&#x000A;  </span><span class="s1">'Discard all apples'</span><span class="w">&#x000A;</span><span class="p">},</span><span class="w"> </span><span class="n">m</span><span class="p">(</span><span class="s1">'aa'</span><span class="p">)</span></pre>&#x000A;&#x000A;<h4 id="prefers-shorter-matching-candidates-over-longer-ones">prefers shorter matching candidates over longer ones</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">c</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s1">'x/tools.sh'</span><span class="p">,</span><span class="w"> </span><span class="s1">'x/torx'</span><span class="w"> </span><span class="p">}</span><span class="w">&#x000A;</span><span class="n">m</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Matcher</span><span class="w"> </span><span class="n">c</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w">&#x000A;  </span><span class="s1">'x/torx'</span><span class="p">,</span><span class="w">&#x000A;  </span><span class="s1">'x/tools.sh'</span><span class="w">&#x000A;</span><span class="p">},</span><span class="w"> </span><span class="n">m</span><span class="p">(</span><span class="s1">'to'</span><span class="p">)</span></pre>&#x000A;&#x000A;<h4 id="prefers-tighter-matches-to-longer-ones">prefers tighter matches to longer ones</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">c</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s1">'awesome_apples'</span><span class="p">,</span><span class="w"> </span><span class="s1">'an_aardvark'</span><span class="w">  </span><span class="p">}</span><span class="w">&#x000A;&#x000A;</span><span class="n">m</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Matcher</span><span class="w"> </span><span class="n">c</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w">&#x000A;  </span><span class="s1">'an_aardvark'</span><span class="p">,</span><span class="w">&#x000A;  </span><span class="s1">'awesome_apples'</span><span class="p">,</span><span class="w">&#x000A;</span><span class="p">},</span><span class="w"> </span><span class="n">m</span><span class="p">(</span><span class="s1">'aa'</span><span class="p">)</span></pre>&#x000A;&#x000A;<h4 id="&quot;special&quot;-characters-are-matched-as-is">&quot;special&quot; characters are matched as is</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">c</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s1">'Item 2. 1%w'</span><span class="p">,</span><span class="w"> </span><span class="s1">'Item 22 2a'</span><span class="w"> </span><span class="p">}</span><span class="w">&#x000A;</span><span class="n">m</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Matcher</span><span class="w"> </span><span class="n">c</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s1">'Item 2. 1%w'</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">m</span><span class="p">(</span><span class="s1">'%w'</span><span class="p">)</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">m</span><span class="p">(</span><span class="s1">'.*'</span><span class="p">)</span></pre>&#x000A;&#x000A;<h4 id="boundary-matches-can-not-skip-separators">boundary matches can not skip separators</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">m</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Matcher</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s1">'nih/says/knights'</span><span class="w"> </span><span class="p">}</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s1">'nih/says/knights'</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">m</span><span class="p">(</span><span class="s1">'sk'</span><span class="p">)</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{},</span><span class="w"> </span><span class="n">m</span><span class="p">(</span><span class="s1">'nk'</span><span class="p">)</span></pre>&#x000A;&#x000A;<h4 id="boundary-matches-are-as-tight-as-possible">boundary matches are as tight as possible</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="ss">how:</span><span class="w"> </span><span class="s1">'boundary'</span><span class="p">,</span><span class="w"> </span><span class="p">{</span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">},</span><span class="w"> </span><span class="p">{</span><span class="mi">6</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">}</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="nc">Matcher</span><span class="p">.</span><span class="n">explain</span><span class="w"> </span><span class="s1">'hth'</span><span class="p">,</span><span class="w"> </span><span class="s1">'hail the howl'</span></pre>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id=""><span class="arg-list">(boundary matches)</span></h2>&#x000A;&#x000A;<h4 id="matches-if-the-search-matches-at-boundaries">matches if the search matches at boundaries</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">m</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Matcher</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s1">'green fields'</span><span class="p">,</span><span class="w"> </span><span class="s1">'green sfinx'</span><span class="w"> </span><span class="p">}</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s1">'green fields'</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">m</span><span class="p">(</span><span class="s1">'gf'</span><span class="p">)</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s1">'apaass_so'</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="nc">Matcher</span><span class="p">({</span><span class="s1">'apaass_so'</span><span class="p">})(</span><span class="s1">'as'</span><span class="p">)</span></pre>&#x000A;&#x000A;<h4 id="matches-if-the-search-matches-at-upper-case-boundaries">matches if the search matches at upper case boundaries</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">m</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Matcher</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s1">'camelCase'</span><span class="p">,</span><span class="w"> </span><span class="s1">'a CreditCard'</span><span class="p">,</span><span class="w"> </span><span class="s1">'chacha'</span><span class="w"> </span><span class="p">}</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s1">'camelCase'</span><span class="p">,</span><span class="w"> </span><span class="s1">'a CreditCard'</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">m</span><span class="p">(</span><span class="s1">'cc'</span><span class="p">)</span></pre>&#x000A;&#x000A;<h4 id="allows-for-multiple-character-boundaries">allows for multiple-character boundaries</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">m</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Matcher</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s1">'green/_fields'</span><span class="p">,</span><span class="w"> </span><span class="s1">'green sfinx'</span><span class="w"> </span><span class="p">}</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s1">'green/_fields'</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">m</span><span class="p">(</span><span class="s1">'gf'</span><span class="p">)</span></pre>&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id="explain">explain<span class="arg-list">(search, text)</span></h2>&#x000A;&#x000A;<h4 id="sets-.how-to-the-type-of-match">sets .how to the type of match</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'exact'</span><span class="p">,</span><span class="w"> </span><span class="nc">Matcher</span><span class="p">.</span><span class="n">explain</span><span class="p">(</span><span class="s1">'fu'</span><span class="p">,</span><span class="w"> </span><span class="s1">'snafu'</span><span class="p">).</span><span class="n">how</span></pre>&#x000A;&#x000A;<h4 id="returns-a-list-of-{start_position,-length}-segments-indicating-where-&lt;search&gt;-matched">returns a list of {start_position, length} segments indicating where &lt;search&gt; matched</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="ss">how:</span><span class="w"> </span><span class="s1">'exact'</span><span class="p">,</span><span class="w"> </span><span class="p">{</span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="mi">3</span><span class="p">}</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="nc">Matcher</span><span class="p">.</span><span class="n">explain</span><span class="w"> </span><span class="s1">'ƒlu'</span><span class="p">,</span><span class="w"> </span><span class="s1">'sñaƒlux'</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="ss">how:</span><span class="w"> </span><span class="s1">'boundary'</span><span class="p">,</span><span class="w"> </span><span class="p">{</span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">},</span><span class="w"> </span><span class="p">{</span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">},</span><span class="w"> </span><span class="p">{</span><span class="mi">9</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">}</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="nc">Matcher</span><span class="p">.</span><span class="n">explain</span><span class="w"> </span><span class="s1">'itʂo'</span><span class="p">,</span><span class="w"> </span><span class="s1">'iʂ that ʂo'</span></pre>&#x000A;&#x000A;<h4 id="lower-cases-the-search-and-text-just-as-for-matching">lower-cases the search and text just as for matching</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">assert</span><span class="p">.</span><span class="n">not_nil</span><span class="w"> </span><span class="nc">Matcher</span><span class="p">.</span><span class="n">explain</span><span class="w"> </span><span class="s1">'FU'</span><span class="p">,</span><span class="w"> </span><span class="s1">'ʂnafu'</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">not_nil</span><span class="w"> </span><span class="nc">Matcher</span><span class="p">.</span><span class="n">explain</span><span class="w"> </span><span class="s1">'fu'</span><span class="p">,</span><span class="w"> </span><span class="s1">'SNAFU'</span></pre>&#x000A;&#x000A;<h4 id="accepts-ustring-both-for-&lt;search&gt;-and-&lt;text&gt;">accepts ustring both for &lt;search&gt; and &lt;text&gt;</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">assert</span><span class="p">.</span><span class="n">not_nil</span><span class="w"> </span><span class="nc">Matcher</span><span class="p">.</span><span class="n">explain</span><span class="w"> </span><span class="s1">'FU'</span><span class="p">,</span><span class="w"> </span><span class="s1">'snafu'</span></pre>&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id="with-reverse-matching">with reverse matching <span class="arg-list">(reverse = true specified as an option)</span></h2>&#x000A;&#x000A;<h4 id="prefers-late-occurring-exact-matches-over-ones-at-the-start">prefers late occurring exact matches over ones at the start</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">c</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s1">'xmatch me'</span><span class="p">,</span><span class="w"> </span><span class="s1">'me xmatch'</span><span class="w"> </span><span class="p">}</span><span class="w">&#x000A;</span><span class="n">m</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Matcher</span><span class="w"> </span><span class="n">c</span><span class="p">,</span><span class="w"> </span><span class="ss">reverse:</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w">&#x000A;  </span><span class="s1">'me xmatch'</span><span class="w">&#x000A;  </span><span class="s1">'xmatch me'</span><span class="p">,</span><span class="w">&#x000A;</span><span class="p">},</span><span class="w"> </span><span class="n">m</span><span class="p">(</span><span class="s1">'mat'</span><span class="p">)</span></pre>&#x000A;&#x000A;<h4 id="prefers-late-occurring-boundary-matches-over-ones-at-the-start">prefers late occurring boundary matches over ones at the start</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">c</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s1">'match natchos'</span><span class="p">,</span><span class="w"> </span><span class="s1">'me match now'</span><span class="w"> </span><span class="p">}</span><span class="w">&#x000A;</span><span class="n">m</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Matcher</span><span class="w"> </span><span class="n">c</span><span class="p">,</span><span class="w"> </span><span class="ss">reverse:</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w">&#x000A;  </span><span class="s1">'me match now'</span><span class="w">&#x000A;  </span><span class="s1">'match natchos'</span><span class="p">,</span><span class="w">&#x000A;</span><span class="p">},</span><span class="w"> </span><span class="n">m</span><span class="p">(</span><span class="s1">'mn'</span><span class="p">)</span></pre>&#x000A;&#x000A;<h4 id="still-prefers-tighter-matches-to-longer-ones">still prefers tighter matches to longer ones</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">c</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s1">'an_aardvark'</span><span class="p">,</span><span class="w"> </span><span class="s1">'a_apple'</span><span class="w"> </span><span class="p">}</span><span class="w">&#x000A;&#x000A;</span><span class="n">m</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Matcher</span><span class="w"> </span><span class="n">c</span><span class="p">,</span><span class="w"> </span><span class="ss">reverse:</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w">&#x000A;  </span><span class="s1">'a_apple'</span><span class="p">,</span><span class="w">&#x000A;  </span><span class="s1">'an_aardvark'</span><span class="p">,</span><span class="w">&#x000A;</span><span class="p">},</span><span class="w"> </span><span class="n">m</span><span class="p">(</span><span class="s1">'aa'</span><span class="p">)</span></pre>&#x000A;&#x000A;<h4 id="still-prefers-boundary-matches-over-straight-ones">still prefers boundary matches over straight ones</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">c</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s1">'some/stuff/here'</span><span class="p">,</span><span class="w"> </span><span class="s1">'sshopen'</span><span class="p">,</span><span class="w"> </span><span class="s1">'open/ssh'</span><span class="p">,</span><span class="w"> </span><span class="s1">'ss xh'</span><span class="w"> </span><span class="p">}</span><span class="w">&#x000A;</span><span class="n">m</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Matcher</span><span class="w"> </span><span class="n">c</span><span class="p">,</span><span class="w"> </span><span class="ss">reverse:</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w">&#x000A;  </span><span class="s1">'open/ssh'</span><span class="p">,</span><span class="w">&#x000A;  </span><span class="s1">'sshopen'</span><span class="p">,</span><span class="w">&#x000A;  </span><span class="s1">'some/stuff/here'</span><span class="w">&#x000A;</span><span class="p">},</span><span class="w"> </span><span class="n">m</span><span class="p">(</span><span class="s1">'ssh'</span><span class="p">)</span></pre>&#x000A;&#x000A;<h4 id="explain(search,-text)-works-correctly">explain(search, text) works correctly</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="ss">how:</span><span class="w"> </span><span class="s1">'exact'</span><span class="p">,</span><span class="w"> </span><span class="p">{</span><span class="mi">7</span><span class="p">,</span><span class="w"> </span><span class="mi">3</span><span class="p">}</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="nc">Matcher</span><span class="p">.</span><span class="n">explain</span><span class="w"> </span><span class="s1">'aƒl'</span><span class="p">,</span><span class="w"> </span><span class="s1">'ƒluxsñaƒlux'</span><span class="p">,</span><span class="w"> </span><span class="ss">reverse:</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="ss">how:</span><span class="w"> </span><span class="s1">'boundary'</span><span class="p">,</span><span class="w"> </span><span class="p">{</span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">},</span><span class="w"> </span><span class="p">{</span><span class="mi">5</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">}</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="nc">Matcher</span><span class="p">.</span><span class="n">explain</span><span class="w"> </span><span class="s1">'as'</span><span class="p">,</span><span class="w"> </span><span class="s1">'app_spec.fu'</span><span class="p">,</span><span class="w"> </span><span class="ss">reverse:</span><span class="w"> </span><span class="kc">true</span></pre>&#x000A;<div class="spec-group spec-group-3">&#x000A;&#x000A;<h3 id="handles-boundary-matches">handles boundary matches</h3>&#x000A;&#x000A;<h4 id="handles-boundary-matches">handles boundary matches</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">m</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Matcher</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s1">'spec/aplication_spec.moon'</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="ss">reverse:</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s1">'spec/aplication_spec.moon'</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">m</span><span class="p">(</span><span class="s1">'as'</span><span class="p">)</span></pre>&#x000A;&#x000A;<h4 id="allows-for-multiple-character-boundaries">allows for multiple-character boundaries</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">m</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Matcher</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s1">'spec/aplication/_spec.moon'</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="ss">reverse:</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s1">'spec/aplication/_spec.moon'</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">m</span><span class="p">(</span><span class="s1">'as'</span><span class="p">)</span></pre>&#x000A;</div>&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id="with-preserve_order-=-true-specified-as-an-option">with preserve_order = true specified as an option</h2>&#x000A;&#x000A;<h4 id="preserves-order-of-matches,-irrespective-of-match-score">preserves order of matches, irrespective of match score</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">c</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="s1">'xabx0'</span><span class="p">,</span><span class="w"> </span><span class="s1">'ax_bx1'</span><span class="p">,</span><span class="w"> </span><span class="s1">'xabx2'</span><span class="p">,</span><span class="w"> </span><span class="s1">'ax_bx3'</span><span class="p">}</span><span class="w">&#x000A;</span><span class="n">m</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Matcher</span><span class="w"> </span><span class="n">c</span><span class="p">,</span><span class="w"> </span><span class="ss">preserve_order:</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="n">c</span><span class="p">,</span><span class="w"> </span><span class="n">m</span><span class="p">(</span><span class="s1">'ab'</span><span class="p">)</span></pre>&#x000A;</div>&#x000A;</div>
      <div class='footer text-muted'>
        <a href='/'>
          <img width="50" height="50" class="footer-logo" src="/images/howl.png" />
        </a>
        <div class='footer-follow'>
          <p>
            <a class='twitter-follow-button' data-lang='en' data-show-count='false' href='https://twitter.com/howleditor' rel='me'>
              Follow @howleditor
            </a>
          </p>
          <p>
            <a class='twitter-share-button' data-count='none' data-hashtags='howleditor' data-lang='en' data-text='The Howl Editor, a general purpose, light-weight customizable editor.' data-url='http://howl.io' href='https://twitter.com/share'>
              Tweet
            </a>
          </p>
        </div>
        <div class='footer-blurb'>
          <div>The Howl editor.</div>
          <div>
            Copyright 2012-2016
            <a class='alert-link' href='https://github.com/howl-editor/howl/contributors'>
              The Howl Developers.
            </a>
          </div>
        </div>
      </div>
    </div>
    <script>
      <!-- / GA -->
      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
      ga('create', 'UA-45283282-1', 'howl.io');
      ga('send', 'pageview');
      <!-- / Twitter -->
      !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];
      if(!d.getElementById(id)){js=d.createElement(s);js.id=id;
      js.src="//platform.twitter.com/widgets.js";
      fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
    </script>
  </body>
</html>
